// 引入请求函数
import {reqTabs,reqDisRec} from 'api'
// 引入mutation类名
import {RECEIVE_TABS,RECEIVE_DISCOVER} from '@/store/mutation-types'
// 定义state
const state = {
  tabsData: {},
  topicData: {}
}
// 定义mutation
const mutations = {
  [RECEIVE_TABS](state,tabsData){
    state.tabsData = tabsData
  },
  [RECEIVE_DISCOVER](state,topicData){
    state.topicData = topicData
  }
}
// 定义action
const actions = {
  async getTabsData({commit}){
    const result = await reqTabs()
    if(result.code==='200'){
      const tabsData = result.data
      commit(RECEIVE_TABS,tabsData)
    }
  },
  async getTopicsData({commit}){
    const result = await reqDisRec()
    if(result.code==='200'){
      const topicData = result.data
      console.log(topicData)
      commit(RECEIVE_DISCOVER,topicData)
    }
  }
}
// 定义getters

// 暴露各个被定义的模块
export default {
  state,
  mutations,
  actions,
}
